package com.aricksm.xuan.activaty02;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import java.util.ArrayList;

/**
 * Created by xuan on 16/6/27.
 */
public class NewsListAcitivity extends Activity implements AdapterView.OnItemClickListener {

    Context mContext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.newslistview);
        mContext = this;

        //1.找到控件
        ListView lv_news = (ListView) findViewById(R.id.lv_news);
        //2.获取新闻数据用list封装
        ArrayList<NewsBean> allNews = NewsUtils.getAllNews(mContext);
        //3.创建一个adapter设置给listview
        NewsAdapter neswAda = new NewsAdapter(mContext, allNews);
        lv_news.setAdapter(neswAda);

        //4.设置listview条目的点击事件
        lv_news.setOnItemClickListener(this);

    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    }
}
